<?php
/**
 * User Class
 *
 */
class OrangeAPI extends MyObject {

	protected $key;
	
	
	public function __construct($key) {
		
		parent::__construct();
		
		$this->key = $key;
	}
	
	public function geoloc($phone) {
	
		$url_geo = "http://location.beta.orange-api.net/location/getLocation.xml?id=".$this->key."&number=".$phone;
		return new GeolocResponse(simplexml_load_string(file_get_contents($url_geo)));
	}
	
	public function clickToCall($from, $to) {
	
		$url = "http://call.beta.orange-api.net/call/createCall.xml?";
		$url .= "id=" . $this->key;
		$url .= "&from=" . $from;
		$url .= "&to=" . $to;
		$url .= "&private=true";
		
		return new ClickToCallResponse( simplexml_load_string(file_get_contents($url)) );
		
	}
	
	public function fetchMMS($dir = './') {
		$mms = new MMS();
		$mms->getData($dir);
		return $mms;
	}
	
	public function fetchSMS() {
		$sms = new SMS();
		$sms->getData();
		return $sms;
	}
	
	public function isMMS() {
		return (!empty($_POST['from']));
	}
	
	public function isSMS() {
		return (!empty($_GET['from']));
	}
}
?>
